home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 April: Mac OS SDK / Dev.CD Apr 96 SDK / Dev.CD Apr 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / Documentation / Tech Notes & Articles / Recipes / Documents / Open Menuitem Recipe < prev   
Encoding:
Text File  |  1995-08-15  |  1.3 KB  |  45 lines  |  [TEXT/ttxt]

  1. OpenDoc™ Recipes
  2.  
  3.  
  4. Open Menuitem Recipe
  5. By The OpenDoc Design Team
  6. August 15th, 1995
  7.  
  8.  
  9. © 1993-1995  Apple Computer, Inc. All Rights Reserved.
  10. Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
  11. Mac and OpenDoc are trademarks of Apple Computer, Inc. 
  12.  
  13.  
  14. Introduction
  15.  
  16. The second item in the OpenDoc “Document” menu is “Open” which a user chooses if they want to open a selected part into a window.  This recipe serves as sample code to do this. 
  17.  
  18. Caveats
  19.  
  20. • This code contains only the essence of the functionality of the Open command
  21.  
  22. • It does not contain proper error checking
  23.  
  24. • It does not account for the case where a part may want to allow “opening” of native content into separate windows.
  25.  
  26. • This sample uses a private field fTCSelection which keeps track of the selection in a part specific manner.  For simplicity’s sake, we assume fTCSelection is an object which supports a few boolean methods regarding the nature of the selection, and supports iterating through the currently selected frames.
  27.  
  28. Sample
  29.  
  30. ...
  31.  
  32. void    CMyPart::OpenSelection()
  33. {
  34.     if  (fTCSelection->EmbeddedFrameSelected())
  35.     {
  36.         ODFrame* frame = fTCSelection->GetFirstSelectedFrame();
  37.         while (frame != kODNULL)
  38.         {
  39.             frame->GetPart()->Open(frame);
  40.             frame = fTCSelection->GetNextSelectedFrame();
  41.         }
  42.     }
  43. }
  44.  
  45.